package org.xqp.hrm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xqp.hrm.dto.SMSCodeSendDto;
import org.xqp.hrm.service.IVerifyCodeService;
import org.xqp.hrm.util.AjaxResult;

//验证码相关
@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    //图片验证
    @GetMapping("/imageCode/{key}")
    public AjaxResult createImageCode(@PathVariable("key") String key) {
        //将验证码图片转换成base64字符串
        String result = verifyCodeService.createImageCode(key);
        return AjaxResult.me().setResultObj(result);
    }

    // 手机短信验证
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody SMSCodeSendDto dto){
        verifyCodeService.sendSmsCode(dto);
        return AjaxResult.me();
    }

}
